package com.pinganfu.tesla.iwallet;

import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

import com.pinganfu.tesla.iwallet.session.SessionManager;
import com.pinganfu.tesla.iwallet.util.TeslaUtil;
import compinganfu.tesla.iwallet.widget.BaseActivity;

public class SplashActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);

		AlphaAnimation aa = new AlphaAnimation(0.8f, 1.0f);
		ImageView splash = (ImageView) findViewById(R.id.imageView1);

		aa.setDuration(1000);
		splash.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation arg0) {
				if (SessionManager.getInstance().getUserPref() == null) {
					TeslaUtil.gotoActivity(SplashActivity.this, OtherLoginActivity.class);
				} else {
					TeslaUtil.gotoActivity(SplashActivity.this, LoginActivity.class);
				}
				finish();
			}
			@Override
			public void onAnimationRepeat(Animation animation) {
			}
			@Override
			public void onAnimationStart(Animation animation) {
			}

		});
	}
}
